#ifndef QQPROTOCOL_H
#define QQPROTOCOL_H
#include <QObject>
#include <QtNetwork>
#include <QNetworkRequest>
#include <QString>
#include <QTextCodec>
#include <QCryptographicHash>
#include "Global.h"
class CVerifyCodeInfo;
class QQProtocol;
class CVerifyCodeInfo
{
public:
    CVerifyCodeInfo();
    ~CVerifyCodeInfo();

public:
    void Reset();
    int Parse(QByteArray&);

private:
    int ParsePtUin(wchar_t * lpInPtUin, char * lpOutPtUin, int& nOutPtUinLen);

public:
    int m_nNeedVerify;
    QString m_strVerifyCode;
    QString m_strVCType;
    char m_cPtUin[1024];
    int m_nPtUinLen;
};



class CLoginResult_1
{
public:
    //CLoginResult_1();
    //~CLoginResult_1();

public:
    void Reset();
    int Parse(QByteArray * Buf, std::vector<QString>* arrRespHeader);

public:
    int m_nRetCode;
    QString m_strMsg;
    QString m_strPtWebQq;
    QString m_strSKey;
};



class QQProtocol : public QObject
{
    Q_OBJECT
protected:
    QBuffer m_Buf;
    QNetworkRequest    m_Request;
    QNetworkReply*      m_pReply;

    QNetworkAccessManager*  m_pManager;
protected:
    int CalcPwdHash(QString lpQQPwd, QString lpVerifyCode,
                    const char * lpPtUin, int nPtUinLen, wchar_t * lpPwdHash, int nLen);
public:
    QQProtocol();
    int CheckVerifyCode(QString strQQNum,	QString strAppId, CVerifyCodeInfo * lpVCInfo);// 检测是否需要输入验证码
    int Logon1(QString lpQQNum, QString lpQQPwd,
               CVerifyCodeInfo *lpVerifyCode,
               CLoginResult_1 * lpLoginResult1,QString lpAppId = WEBQQ_APP_ID);
};

#endif // QQPROTOCOL_H
